<?php



include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");

include_once($_SERVER["DOCUMENT_ROOT"] . "/include/user/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/mblog/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/album/inc.php");
$g_cgival = array();
$g_pro = array();
$g_show = array();

function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	//check refer  -  add by xinwei
	if(! security_check::check_refer())
	{
		throw new Exception("来路不明");
	}
	
	cgi::both($g_cgival["id"], "id", "");
	$g_cgival["id"] = string::un_html($g_cgival["id"]);
	
	
	cgi::both($g_cgival["type"], "type", "add");
	$g_cgival["type"] = string::un_html($g_cgival["type"]);
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$id = $g_cgival["id"];
	if(!$id)
	{
		throw new Exception("id不能为空！");
	}
	$uid = admin::admin_get_login_uid();
	$nickname = admin::admin_get_login_user_name();
	
	$db_mblog_pic_content = new db_mblog_pic_content();
	
	$db_album_info = new db_album_info();
	
	if($g_cgival["type"] == "del")
	{
		$db_album_info->admin_update_by_id($id,0);
		
	}
	
	elseif($g_cgival["type"] == "undel")
	{
		$db_album_info->admin_update_by_id($id,1);
		
	}
	

}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_list.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
	{
		print_r($g_show);
		exit;
	}
	
	
	echo json_encode($g_show);
}

